<?php

use Doraemon\tools\HhzEnv;

ini_set('display_errors', 1);
require_once '/data/wwwroot/g_vendor/autoload.php';




$conf = \Biz\service\advertisement\AdUserProfileManagement::getConf();

$typeGroup = [];
foreach ($conf as $v) {
    if ($v['show_option'] == 5) continue;
    $rewrite = \Biz\service\advertisement\AdUserProfileManagement::moduleFileExists($v['column_field']) ? 'yes' : '';
    $typeGroup[$v['form_type']][] = implode("\t", [$v['id'], $v['column_field'], $v['column_name'], \Biz\model\advertisement\MHhzPositionUserprofile::SIGN_TYPE_MAP[$v['sign']], $rewrite]);
}
foreach ($typeGroup as $key => $group) {
    foreach ($group as $v) {
        echo \Doraemon\service\position\DisplayConstInterface::ADM_FORM_TYPE_MAP[$key] ?? '', "\t", $v, PHP_EOL;
    }
}

exit;

$id = 0;
$rules = [];
while (true) {
    $list = \Biz\model\advertisement\MPositionRules::select('*', ['id[>]' => $id, 'LIMIT' => 5000]);

    if (empty($list)) {
        break;
    }
    $ids = array_column($list, 'id');
    $id = max($ids);
    echo $id, PHP_EOL;
    $rules = array_merge($rules, $list);
}
var_dump(count($rules));
foreach ($rules as $rule) {
    $value = $conf[$rule['rule_type']]['column_field'];
    \Biz\model\advertisement\MPositionRules::update(['rule_field' => $value], ['id' => $rule['id'], 'rule_field' => '']);
}


